import type { PageType, ResponseType } from '@/api/common/type';
import request from '@/utils/request';
import type { TrademarkType } from './type';

enum ProductConstant {
	PAGE_URL = '/admin/product/baseTrademark',
	SAVE_URL = '/admin/product/baseTrademark/save',
	UPDATE_URL = '/admin/product/baseTrademark/update',
	DELETE_URL = '/admin/product/baseTrademark/remove',
}
/**
 * trademark的分页请求
 * @param page 当前页
 * @param limit 每页记录条数
 * @returns promise
 */
export const reqPageTrademark = (
	page: number = 1,
	limit: number = 1
): Promise<ResponseType<PageType<TrademarkType>>> => {
	return request.get(ProductConstant.PAGE_URL + `/${page}/${limit}`);
};

/**
 * 添加trademark
 * @param trademark
 * @returns
 */
export const reqSaveTrademark = (
	trademark: TrademarkType
): Promise<ResponseType<any>> => {
	return request.post(ProductConstant.SAVE_URL, trademark);
};

/**
 * 更新trademark
 * @param trademark
 * @returns
 */
export const reqUpdateTrademark = (
	trademark: TrademarkType
): Promise<ResponseType<any>> => {
	return request.put(ProductConstant.UPDATE_URL, trademark);
};

/**
 * 根据删除trademark
 * @param id
 * @returns
 */
export const reqDeleteTrademark = (id: number): Promise<ResponseType<any>> => {
	return request.delete(ProductConstant.DELETE_URL + `/${id}`);
};
